home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Yerk 3.6.8 / tool+ / textEdit < prev    next >
Encoding:
Text File  |  1994-11-29  |  3.9 KB  |  127 lines  |  [TEXT/YERK]

  1. \ textEdit class based on bjr 1987
  2. \ 12.11.89    rfl now subclass of handle
  3. \ A lot of these methods leave the current font of the window changed.
  4. \ 4.17.91    rfl fixed rect1...actually should move into rect
  5. \ 4.23.91    rfl    added addText:
  6. \ 10.14.92    rfl    added scrap handing stuff
  7. \ 10.18.91    rfl    protect for 32k limit
  8. \ 2.22.94    rfl    added autoView
  9. \ 9.28.94    rfl    changed rsrc string number on new:
  10. \ 10.8.94    rfl    added shift? to click: method; changed highlight: to selectAll:
  11.  
  12. $ 7fff value teLimit
  13.  
  14. string teScrap
  15.  
  16. : !TeScrap global TEScrpHandle @ teScrap ! ;
  17. \ words to get and put the text edit scrap
  18. : GetTeScrap ( -- addr len) !TeScrap get: teScrap ;
  19. : putTeScrap ( addr len --) !TeScrap put: teScrap size: teScrap global teScrpLength w! ;
  20. : teScrap>Scrap call zeroScrap !TeScrap lock: teScrap 0 size: teScrap TxType ptr: teScrap
  21.         +base call putScrap drop unlock: teScrap ;
  22. : scrap>teScrap  getScrap drop lock: parmstr get: parmstr putTeScrap unlock: parmstr ;
  23.  
  24.  
  25. \ : GetTeScrap ( -- addr len) global TEScrpHandle @ >ptr global TEScrpLength w@ ;
  26. \ : PutTeScrap { addr len \ temp -- } len global TEScrpLength w! global TeScrpHandle @
  27. \         heap> string -> temp temp ! addr len put: temp dispose> temp ;
  28. \ \ put the text edit scrap into the scrap
  29. \ : teScrap>Scrap { \ addr len -- } call zeroScrap getTeScrap -> len -> addr
  30. \         0 len TxType addr +base call putScrap drop ;
  31. \ \ scrap to text edit scrap
  32. \ : scrap>teScrap  getScrap drop lock: parmstr get: parmstr putTeScrap unlock: parmstr ;
  33.  
  34. :CLASS TextEdit <Super handle
  35.  
  36.     Rect ViewRect        \ as in IM V1
  37.     Rect DestRect        \ ditto
  38.  
  39.   :M  PtIn: ( -- b) where: theMouse pack ptIn: viewrect ;M 
  40.   :M  TEString: ( addr len  -- AbsAddr Length) swap +Base swap ;M
  41.   
  42.   \ first set up rects
  43.   :M  New: { myWind  -- }
  44.         alive: myWind not classerr" 192
  45.         PushPort set: myWind
  46.         0 Abs: DestRect Abs: ViewRect Call TENew m!
  47.         PopPort ;M
  48.  
  49.   :M  alive: ( -- b) m@ 0 <> ;M
  50.  
  51.   :M  close: m@ -dup IF Call TEDispose 0 m! THEN ;M
  52.   
  53.   :M  justify: ( Just --) MakeInt m@ Call TESetJust ;M
  54.   
  55.   :M  SetSelect: ( Start End --) m@ Call TESetSelect ;M
  56.   
  57.   :M  selectAll: 0 $ 7fff setSelect: self ;M
  58.  
  59.   :M  hilite: selectAll: self ;M
  60.  
  61.   :M  moveTo: ( Position --) Dup SetSelect: Self ;M
  62.   
  63.   :M  Activate: m@ Call TEActivate ;M
  64.   
  65.   :M  Deactivate: m@ Call TEDeactivate ;M
  66.  
  67.   :M  teCut: m@ Call TECut ;M
  68.   
  69.   :M  teCopy: m@ Call TECopy ;M
  70.   
  71.   :M  tePaste: m@ Call TEPaste ;M
  72.  
  73.   :M  teDelete: m@ Call TEDelete ;M
  74.  
  75.   :M  PutText: ( addr len --) TEString: Self m@ Call TESetText ;M
  76.   
  77.   :M  GetText: ( -- addr len)
  78.         0 m@ Call TEGetText >ptr ptr: self 60 + w@  ;M
  79.  
  80.   :M  ReCal: m@ call TECalText ;M
  81.  
  82.   :M  textSize: ( -- len) getText: self swap drop ;M
  83.   
  84.   :M  overLimit?: ( len -- len b) dup textSize: self + teLimit > ;M
  85.  
  86.   :M  clear: 0 textSize: self setSelect: self TEDelete: self ;M
  87.   
  88.   :M  Insert: ( addr len --) TEString: Self m@ Call TEInsert ;M
  89.   
  90.   :M  Key: ( char --) MakeInt m@ Call TEKey ;M
  91.   
  92. \ could change teDelete to TeCut to do something with top of text
  93. \ for right now, delete twice the new addition and creep up to top again
  94.   :M  AddText: ( addr len --) overLimit?: self
  95.         IF 0 over 2* setSelect: self teDelete: self
  96.         THEN
  97.         textSize: self 1+ moveto: self insert: self ;M
  98.  
  99.   :M  Draw: clear: destRect
  100.         Abs: destRect m@ Call TEUpdate ;M
  101.   
  102.   :M  print:  abs: destRect m@ call TEUpdate ;M
  103.   
  104.   :M  Scroll: ( dh dv--)    pack m@ Call TEScroll ;M
  105.  
  106.   :M  Click: where: themouse pack shift? Bool m@ Call TEClick ;M
  107.   
  108.   :M  Idle: m@ Call TEIdle ;M
  109.   
  110.   :M  PutRect: ( l t r b --) put: viewRect  get: viewRect put: destRect
  111.         m@ IF get: destRect ptr: self put: rect
  112.               get: viewRect ptr: self 8+ put: rect
  113.             THEN ;M
  114.  
  115.   :M  ChangeRect: get: destRect ptr: self put: rect get: viewRect ptr: self 8+ put: rect ;M
  116.   
  117.   :M  OffSet: { dx dy -- }
  118.         dx dy OffSet: viewRect get: viewRect put: destRect ;M
  119.   
  120.   :M  InsetDest: ( dx dy --) Inset: DestRect ;M
  121.  
  122.   :M  autoView: ( b --) bool m@ call teAutoView ;M
  123.  
  124. ;CLASS
  125.